<!--
  - Copyright(c)  2022 厦门外里科技有限公司 All rights reserved.
  -
  - https://www.wailikeji.com
  -
  - 版权所有，侵权必究！
  -->

<template>
	<view class="scrool-page">
		<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="loadMore" lower-threshold="10upx">
			<view class="page-box">
				<view class="order" v-for="(item, index) in itemList" :key="index">
					<view>
						<view style="color: #999999;font-size: 28upx;">
							<view style="margin-bottom: 8upx"> 订单号：{{item.orderId}}</view>
							<view style="margin-bottom: 8upx"> 提现方式：{{getCardType(item.cardType)}}</view>
							<view style="margin-bottom: 8upx"> 姓名：{{item.cardName}}</view>
							<view style="margin-bottom: 8upx"> {{getAcountType(item.cardType)}}：{{item.cardNumber}}
							</view>
							<!-- 人工支付或余额支付 -->
							<view style="margin-bottom: 8upx;display: flex;"> 状态：
								<view v-if="item.status==-2" style="font-size: 28upx; color:#FD6416"> 取消</view>
								<view v-else-if="item.status==-1" style="font-size: 28upx; color:#FD6416"> 审核不过</view>
								<view v-else-if="item.status==0" style="font-size: 28upx; color:#FD6416"> 待审核。。。
								</view>
								<view v-else-if="item.status==1" style="font-size: 28upx; color:#4fc08d">提现成功</view>
								<u-button v-if="item.status==0" @click="cancelHandler(item.id)"
									style="font-size: 28upx; color:#FD6416; height: 50upx; width: 100upx; right: -130upx; top: -50upx;">
									取消</u-button>
								<image v-if="item.status<0" src="../../static/images/my/order/refuse.jpeg"
									style="height: 50upx; width: 50upx; margin-left:380upx ; top: -50upx;"></image>
								<image v-else-if="item.status==1" src="../../static/images/my/order/success.jpeg"
									style="height: 50upx; width: 50upx; margin-left:380upx ; top: -50upx;"></image>
							</view>
							<view style="margin-bottom: 8upx"> 审核备注：{{item.auditRemark}}</view>
							<view style="margin-bottom: 8upx"> 订单时间：{{item.createTime}}</view>
							<view
								style="display: flex;float:right; margin-top: -45upx; margin-bottom: 0upx;text-align: right;">
								<!-- 提现金额： -->
								<view style="display: flex;float:right;">
									<text style=" color: #FD6416;font-size: 32upx;font-weight: 600">
										¥ {{item.withdrawValue}}
									</text>
								</view>
							</view>
						</view>

					</view>
				</view>
				<u-loadmore v-if="itemList.length>4" :status="loadStatus" bgColor="#f2f2f2"></u-loadmore>
				<view v-if="itemList.length===0" style="text-align: center;margin-top: 60px">暂无记录</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				loadStatus: 'loadmore',
				curPage: 0,
				itemList: []
			}
		},
		onShow() {
			if (this.itemList.length == 0) {
				this.loadMore()
			}
		},
		//下拉刷新
		onPullDownRefresh() {
			this.refresh()
		},
		methods: {
			getAcountType(cardType) {
				if (cardType === 0) {
					return "支付宝账号"
				} else if (cardType === 1) {
					return "微信账号"
				} else {
					return "银行卡号"
				}
			},
			getCardType(cardType) {
				if (cardType === 0) {
					return "支付宝"
				} else if (cardType === 1) {
					return "微信"
				} else {
					return "银行卡"
				}
			},
			/**
			 * 刷新
			 */
			refresh() {
				this.itemList = []
				this.curPage = 0
				this.loadStatus = 'loadmore'
				this.loadMore()

			},
			//取消订单
			cancelHandler(id) {
				console.log("id=" + id)
				this.$api.apiPath('withdraw.cancel', "/" + id)
					.then(res => {
						console.log("进入信息", res)
						if (res.code == 200) {
							this.refresh()
						} else {
							uni.showToast({
								icon: 'none',
								position: 'bottom',
								title: res.msg
							});
						}
					})
			},
			loadMore() {
				if (this.loadStatus == 'nomore') {
					return
				}
				//加载中
				this.loadStatus = 'loading';
				let page = this.curPage + 1
				this.$api.api('withdrawOrder.list', {
						"pageNum": page,
						"pageSize": 10,
						"orderByColumn": "createTime",
						"isAsc": "descending"
					})
					.then(res => {
						if (res.code == 200) {
							this.itemList = this.itemList.concat(res.rows)
							if (res.total > this.itemList.length) {
								this.loadStatus = 'loadmore';
								this.curPage++;
							} else {
								this.loadStatus = 'nomore';
							}
						} else {
							uni.showToast({
								icon: 'none',
								position: 'bottom',
								title: res.msg
							});
						}
						uni.stopPullDownRefresh(); //停止下拉刷新动画
					})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		height: 100%; //加载更多需要
		background: #f8f8f8;
	}

	.scrool-page {
		height: 100%; //加载更多需要
	}

	.order {
		background-color: #ffffff;
		margin: 32rpx; //上下间距
		border-radius: 20rpx; //倒角
		padding: 32rpx;
		font-size: 28rpx;
		box-shadow: 0 2upx 2upx rgba(183, 183, 183, 0.3); //周边阴影
	}
</style>
